package cn.gson.oasys.controller.AoaDiscussListControler;

import cn.gson.oasys.pojo.AoaDiscussList;
import cn.gson.oasys.service.AoaDiscussList.AoaDiscussListService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2020/12/4.
 */
@Controller
public class AoaDiscussListController {
    @Resource
    private AoaDiscussListService service;

    //定义所需参数
    Integer likeNum = 0; //点赞数
    Integer commentNum = 0; //评论数

    //分页查询查询讨论列表 王义
    @RequestMapping("getAllDiscuss")
    @ResponseBody
    public Object getAllDiscuss(Integer pageNo, Integer pageSize){
        PageHelper.offsetPage((pageNo-1)*pageSize,pageSize);
        List<AoaDiscussList> aoaDiscussList =  service.getAllDiscussList();
        PageInfo<AoaDiscussList> pageInfo=new PageInfo<AoaDiscussList>(aoaDiscussList);
        return pageInfo;
    }

    //根据标题查询讨论列表
    @RequestMapping("getAllDiscussByTitle")
    @ResponseBody
    public List<AoaDiscussList> getAllDiscussByTitle(String title){
        List<AoaDiscussList> discussLists = service.getAllDiscuss(title);
        return discussLists;
    }




}
